﻿<!doctype html>
<html xmlns:wb=“http://open.weibo.com/wb”>
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
<head>
  <meta charset="utf-8">

  <title>气象站</title>

  <link href="application.css" media="all" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>    
    <script type="text/javascript" src="js/moment.min.js"></script> 
    <script type="text/javascript" src="../js/angular-1.5.8/angular.min.js" ></script>
    <script type="text/javascript" src="js/pub.js" ></script>
	<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js" type="text/javascript" charset="utf-8"></script>
	
    <script type="text/javascript">

        var ls = [];
        var app = angular.module('ws', []);
        app.controller('index', function ($scope, $timeout) {
            
            $.get("index.json",
                function (data) {
                    ls = eval(data);
                    $timeout(function () {
                        $scope.ls = ls;            
                    }, 10);
                    val_ref(); 
            });
            
            function val_ref(){
                //log(ls.length);
                for(i = 0; i < ls.length; i++){
                    var d_id = ls[i].id;
                    var key = ls[i].key;
                    //log(ls[i].id + ", " + ls[i].key);
                    
                    $.get("main.php", {cmd: "getdatalast", div: d_id, key: key, id_temp: Math.random()}, function(data) {
                        data = eval("(" + data + ")");

                        for(j = 0; j < ls.length; j++){
                            if(ls[j].id == data.div)
                                ls[j].val = Math.round(data.dat * 10) / 10;
                            
                            if(j == ls.length - 1){
                                $timeout(function () {
                                    $scope.ls = ls;            
                                }, 10);
                            }
                            
                        }
                        
                        if(data.div == "v1") {
                            $("#dat").empty();
                            $("#dat").append("数据更新时间：" + moment(data.lab,"YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm") );
                        }
                    })
                    
                }
                $timeout(function () {
                        val_ref();       
                    }, 60 * 1000);
            };

        });
    </script>
</head>

<body class="aqis_live_data" ng-app="ws" ng-controller="index">
  <div class="container">
  <div class="span12 avg">
    <div class="span11">
      <div class="city_name">
          <h2>气象站</h2>
      </div> <!-- end of .city_name -->
      <div class="level">
          <h4>
            
          </h4>
      </div> <!-- end of .level -->
    </div> <!-- end of .span11 -->
    
    <div class="span11">
      <div class="live_data_time">
          <p id="dat">数据更新时间：2016-04-17 12:00:00</p>
      </div> <!-- end of .live_data_time -->
      <div class="live_data_unit">
        <!--数值单位：μg/m3(CO为mg/m3)-->
      </div> <!-- end of live_data_unit -->
    </div> <!-- end of .span11 -->

    <div class="span12 data">
        <div class="span1" ng-repeat="x in ls">
          <div id="{{x.id}}" key="{{x.key}}" class ="value">
              {{x.val}}
          </div>
          <div class="caption">
          {{x.caption}}
          </div>
        </div>

        <div class="span1 more-city">
          <div class="value">
            <a href="/">其他城市</a>
          </div>
        </div>
    </div> <!-- end of .data -->

    <div class="span12 caution" >
      <div class="primary_pollutant">
          <p>
            &nbsp;
          </p>
      </div> <!-- end of .primary_pollutant -->
      <div class="affect">
          <p>
            &nbsp;
          </p>
      </div> <!-- end of .affect -->
      <div class="action">
          <p>
            &nbsp;
          </p>
      </div> <!-- end of .action -->
    </div> <!-- end of .caution -->
  </div> <!-- end of .avg -->

  <div class="" >

    <iframe src="chart.php" style="border: 0px currentColor; border-image: none; width: 100%; height: 520px;"></iframe>

  </div>
  
  <div class="table" style="text-align:center">
	<wb:share-button appkey="3673553477" addition="number" type="button"></wb:share-button> 
  </div>

  <div class="span12 history">
    <div id="history_chart"></div>
  </div>

    <div class="footer">
	
      <p>
		
		Copyright ? 2013-2017 <a>w_p_</a> All Rights Reserved.
      </p>
	  
      <p>
        <a href="http://www.miibeian.gov.cn/" target="_blank"></a>
      </p>
    </div>
    <div id="back-top">
      <a href="#top"><span></span>回到顶部</a>
    </div>
  </div>

</body>
</html>